package com.globaleducation365.cartoonv1.horizontal;

import java.util.ArrayList;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.globaleducation365.cartoon.R;
import com.globaleducation365.cartoonv1.entity.InfoVideo;

public class CustomListAdapter extends ArrayAdapter<InfoVideo> {
	Context context;
	private ArrayList<InfoVideo> list;
	int layoutId;
	Holder holder;
	public View view;
	public int currPosition = 0;

	public CustomListAdapter(Context context, int textViewResourceId,
			ArrayList<InfoVideo> list) {
		super(context, R.layout.item_video_index, list);
		this.context = context;
		this.list = list;
		layoutId = textViewResourceId;

	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public InfoVideo getItem(int position) {
		return list.get(position);
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		RelativeLayout layout;
		if (convertView == null) {

			layout = (RelativeLayout) View.inflate(context, layoutId, null);

			holder = new Holder();

			// holder.title = (TextView)
			// layout.findViewById(R.id.txtNewsSource);
			layout.setTag(holder);

		} else {
			layout = (RelativeLayout) convertView;
			view = layout;
			holder = (Holder) layout.getTag();
		}
		// String newsSource = getItem(position);
		// holder.title.setText(newsSource);
		Log.v("Test", "lo frm newsadpater");

		return layout;
	}

	private class Holder {
		public TextView title;

	}

	public int getCurrentPosition() {
		return currPosition;
	}
}
